<?php
    session_start();
    include_once '../../../../controlador/php/conexion/Conexion.php';
    $con = new Conexion();
    
    //edicion control y signos vitales antes de la transfusion
    //oids tablas-> libroTrans,controlTrans,signosV
    $ltr = $_REQUEST['ltr_oid'];
    $cont = $_REQUEST['con_oid'];
    //$sig = $_REQUEST['sig_signo'];
    
    //datos controlTrans 
    $cants = $_REQUEST['cants'];
    $cante = $_REQUEST['cante'];
    $teml = $_REQUEST['teml'];
    $horai = $_REQUEST['horai'];
    $horaf = $_REQUEST['horaf'];
    $med = $_REQUEST['med'];
    $obs = $_REQUEST['obs'];
    
    
    $signosat = "update controlTrans
                set usu_oidm= ".$_SESSION['usuario'].",
                    con_cants = '".$cants."',
                    con_cante = '".$cante."',
                    con_teml = '".$teml."',
                    con_hi = '".$horai."',
                    con_hf = '".$horaf."',
                    genMedicoc = '".$med."'
                 from controlTrans inner join usuario on controlTrans.usu_oidm=usuario.usu_oid
				    inner join signosV on controlTrans.con_oid=signosV.con_oid
                 where ltr_oid = ".$ltr." and controlTrans.con_oid = ".$cont;
    $con->query($signosat);
    
    
   //signos vitales antes de la transfusion
    $ta = $_REQUEST['ta'];
    $t = $_REQUEST['t'];
    $fc = $_REQUEST['fc'];
    $fr = $_REQUEST['fr'];
    $so = $_REQUEST['so'];
    
    
    $sigat = "update signosV
              set sig_ta = '".$ta."',
                  sig_t = '".$t."',
                  sig_fc = '".$fc."',
                  sig_fr = '".$fr."',
                  sig_saox = '".$so."',
                  sig_obs = '".$obs."',
                  sig_fhora = GETDATE()
              from controlTrans inner join signosV on controlTrans.con_oid=signosV.con_oid
              where ltr_oid = '".$ltr."' and controlTrans.con_oid = ".$cont." and sig_signo = 'at'";
    $con->query($sigat);
    
    //signos vitales 15
    $ta15 = $_REQUEST['ta15'];
    $t15 = $_REQUEST['t15'];
    $fc15 = $_REQUEST['fc15'];
    $fr15 = $_REQUEST['fr15'];
    $so15 = $_REQUEST['so15'];
    $obs15 = $_REQUEST['obs15'];
    $reac15 = $_REQUEST['reac15'];
    
    $sig15 = "update signosV
              set sig_ta = '".$ta15."',
                  sig_t = '".$t15."',
                  sig_fc = '".$fc15."',
                  sig_fr = '".$fr15."',
                  sig_saox = '".$so15."',
                  sig_obs = '".$obs15."',
                  sig_reac = '".$reac15."',
                  sig_fhora = GETDATE()
              from controlTrans inner join signosV on controlTrans.con_oid=signosV.con_oid
              where ltr_oid = '".$ltr."' and controlTrans.con_oid = ".$cont." and sig_signo = '15'";
    $con->query($sig15);
    
    //signos vitales 30
    $ta30 = $_REQUEST['ta30'];
    $t30 = $_REQUEST['t30'];
    $fc30 = $_REQUEST['fc30'];
    $fr30 = $_REQUEST['fr30'];
    $so30 = $_REQUEST['so30'];
    $obs30 = $_REQUEST['obs30'];
    $reac30 = $_REQUEST['reac30'];
    
    $sig30 = "update signosV
              set sig_ta = '".$ta30."',
                  sig_t = '".$t30."',
                  sig_fc = '".$fc30."',
                  sig_fr = '".$fr30."',
                  sig_saox = '".$so30."',
                  sig_obs = '".$obs30."',
                  sig_reac = '".$reac30."',
                  sig_fhora = GETDATE()
              from controlTrans inner join signosV on controlTrans.con_oid=signosV.con_oid
              where ltr_oid = '".$ltr."' and controlTrans.con_oid = ".$cont." and sig_signo = '30'";
    $con->query($sig30);
    
    //signos vitales 60
    $ta60 = $_REQUEST['ta60'];
    $t60 = $_REQUEST['t60'];
    $fc60 = $_REQUEST['fc60'];
    $fr60 = $_REQUEST['fr60'];
    $so60 = $_REQUEST['so60'];
    $obs60 = $_REQUEST['obs60'];
    $reac60 = $_REQUEST['reac60'];
    
    $sig60 = "update signosV
              set sig_ta = '".$ta60."',
                  sig_t = '".$t60."',
                  sig_fc = '".$fc60."',
                  sig_fr = '".$fr60."',
                  sig_saox = '".$so60."',
                  sig_obs = '".$obs60."',
                  sig_reac = '".$reac60."',
                  sig_fhora = GETDATE()
              from controlTrans inner join signosV on controlTrans.con_oid=signosV.con_oid
              where ltr_oid = '".$ltr."' and controlTrans.con_oid = ".$cont." and sig_signo = '60'";
    $con->query($sig60);
    
    //signos vitales 1h
    $ta1h = $_REQUEST['ta1h'];
    $t1h = $_REQUEST['t1h'];
    $fc1h = $_REQUEST['fc1h'];
    $fr1h = $_REQUEST['fr1h'];
    $so1h = $_REQUEST['so1h'];
    $obs1h = $_REQUEST['obs1h'];
    $reac1h = $_REQUEST['reac1h'];
    
    $sig1h = "update signosV
              set sig_ta = '".$ta1h."',
                  sig_t = '".$t1h."',
                  sig_fc = '".$fc1h."',
                  sig_fr = '".$fr1h."',
                  sig_saox = '".$so1h."',
                  sig_obs = '".$obs1h."',
                  sig_reac = '".$reac1h."',
                  sig_fhora = GETDATE()
              from controlTrans inner join signosV on controlTrans.con_oid=signosV.con_oid
              where ltr_oid = '".$ltr."' and controlTrans.con_oid = ".$cont." and sig_signo = '1h'";
    $con->query($sig1h);
    
    
    $con->cerrarConexion();
    
    //print_r(json_encode(array('mensaje'=>'Los datos se editaron correctamente')));
?>
